summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuo Jinghua <sunmoon1997@gmail.com>2010-03-01 14:39:55 +0800
committerLuo Jinghua <sunmoon1997@gmail.com>2010-03-01 14:39:55 +0800
commit2e8d31b96178aaf95c4c71c36580be4f0008781f (patch)
tree5813abe7a590bb3f8813bae972235539cfdf571e
parent72a94a4ad7b26cc295b642c9fd3e2ad3fb2b6359 (diff)
Device: support another st device
-rw-r--r--configure.in9
-rw-r--r--src/device.cpp15
-rw-r--r--src/device_zte.cpp79
-rw-r--r--src/device_zte.h33
4 files changed, 135 insertions, 1 deletions
diff --git a/configure.in b/configure.in
index bd00ade..6444494 100644
--- a/configure.in
+++ b/configure.in
@@ -176,7 +176,7 @@ AC_CHECK_HEADER(sys/soundcard.h,
AC_DEFINE(HAVE_OSS))
AM_CONDITIONAL(HAVE_OSS, test "x$HAVE_OSS" = "xtrue")
-AC_CHECK_HEADER(alsa/asoundlib.h,
+AC_CHECK_LIB(asound, snd_pcm_open,
HAVE_ALSA=true
LIBS="-lasound $LIBS"
AC_DEFINE(HAVE_ALSA))
@@ -189,6 +189,13 @@ AC_CHECK_LIB(nexus, NEXUS_Platform_Init,
EXTRA_LIBS="-lnexus $EXTRA_LIBS")
AM_CONDITIONAL(HAVE_NEXUS, test "x$HAVE_NEXUS" = "xtrue")
+AC_CHECK_LIB(mplayer, Music_device_open,
+ HAVE_ZTE=true
+ AC_DEFINE(HAVE_ZTE)
+ LIBS="-lmplayer $LIBS"
+ EXTRA_LIBS="-lmplayer $EXTRA_LIBS")
+AM_CONDITIONAL(HAVE_ZTE, test "x$HAVE_ZTE" = "xtrue")
+
AC_CHECK_HEADER(vorbis/vorbisfile.h,
HAVE_OGG=true
LIBS="-lvorbisfile -lvorbis -logg $LIBS"
diff --git a/src/device.cpp b/src/device.cpp
index a301a19..0026392 100644
--- a/src/device.cpp
+++ b/src/device.cpp
@@ -20,6 +20,10 @@
#endif
+#ifdef HAVE_ZTE
+ #include "device_zte.h"
+#endif
+
#ifdef HAVE_ALSA
#include "device_alsa.h"
#endif
@@ -164,6 +168,9 @@ namespace audiere {
"alsa:Advance Linux Sound Architecture" ";"
#endif
#ifdef HAVE_NEXUS
+ "zte:ZTE Audio" ";"
+#endif
+#ifdef HAVE_NEXUS
"nexus:Nexus Audio" ";"
#endif
#ifdef HAVE_OSS
@@ -239,6 +246,7 @@ namespace audiere {
TRY_GROUP("al");
TRY_GROUP("directsound");
TRY_GROUP("winmm");
+ TRY_GROUP("zte");
TRY_GROUP("alsa");
TRY_GROUP("nexus");
TRY_GROUP("oss");
@@ -246,6 +254,13 @@ namespace audiere {
return 0;
}
+ #ifdef HAVE_ZTE
+ if (name == "zte") {
+ TRY_DEVICE(ZteAudioDevice);
+ return 0;
+ }
+ #endif
+
#ifdef HAVE_ALSA
if (name == "alsa") {
TRY_DEVICE(ALSAAudioDevice);
diff --git a/src/device_zte.cpp b/src/device_zte.cpp
new file mode 100644
index 0000000..51bee75
--- /dev/null
+++ b/src/device_zte.cpp
@@ -0,0 +1,79 @@
+#include <algorithm>
+#include <string>
+#include <stdio.h>
+#include <unistd.h>
+#include <fcntl.h>
+
+#include "MusicPlay.h"
+
+#include "device_zte.h"
+#include "debug.h"
+
+
+namespace audiere {
+
+ ZteAudioDevice*
+ ZteAudioDevice::create(const ParameterList& parameters) {
+ int ret;
+
+ ret = Music_device_open();
+ if (ret < 0)
+ {
+ ADR_LOG("Unable to open playback device\n");
+ return 0;
+ }
+
+ ret = Music_device_ioctl(VOD_PLAY, MUSIC_TYPE_PCM_44K);
+ if (ret < 0)
+ {
+ ADR_LOG("Unable to set device to play state\n");
+ Music_device_close(0);
+ return 0;
+ }
+
+ return new ZteAudioDevice(44100, 4096);
+ }
+
+ ZteAudioDevice::ZteAudioDevice(int rate,
+ int buffer_size)
+ : MixerDevice(rate), m_rate(rate)
+ {
+ m_buffer_size = buffer_size;
+ m_buffer = new char [buffer_size];
+ }
+
+
+ ZteAudioDevice::~ZteAudioDevice() {
+ ADR_GUARD("ZteAudioDevice::~ZteAudioDevice");
+
+ Music_device_close(0);
+ delete [] m_buffer;
+ }
+
+
+ void ADR_CALL
+ ZteAudioDevice::update() {
+ int sample_len;
+ size_t sample_left;
+ char* sample_buf;
+
+ sample_buf = m_buffer;
+ sample_len = m_buffer_size / 4;
+
+ sample_left = read(sample_len, sample_buf);
+ while (sample_left > 0) {
+ if (Music_device_write(sample_buf, sample_left * 4) < 0) {
+ AI_Sleep(2);
+ } else {
+ sample_left = 0;
+ }
+ }
+ }
+
+
+ const char* ADR_CALL
+ ZteAudioDevice::getName() {
+ return "zte";
+ }
+
+}
diff --git a/src/device_zte.h b/src/device_zte.h
new file mode 100644
index 0000000..dfbc849
--- /dev/null
+++ b/src/device_zte.h
@@ -0,0 +1,33 @@
+#ifndef DEVICE_ZTE_H
+#define DEVICE_ZTE_H
+
+
+#include "audiere.h"
+#include "device_mixer.h"
+
+
+namespace audiere {
+
+ class ZteAudioDevice : public MixerDevice {
+ public:
+ static ZteAudioDevice* create(const ParameterList& parameters);
+
+ private:
+ ZteAudioDevice(int rate,
+ int buffer_size);
+ ~ZteAudioDevice();
+
+ public:
+ void ADR_CALL update();
+ const char* ADR_CALL getName();
+
+ private:
+ int m_buffer_size;
+ char* m_buffer;
+ int m_rate;
+ };
+
+}
+
+
+#endif