Permalink
Browse files

Remove audio half volume since it's no longer used. Fix a threading i…

…ssue and differentiate media vs. any audio focus. Fix some corner cases in button handling wrt to focus. Simplify the audio focus handling turns out I was wrong and the channel is always AA_CH_CTR :(
  • Loading branch information...
lmagder committed Nov 18, 2017
1 parent 3655b7d commit 77bac847103f08676fc56a040117a04ca77301a1
Showing with 192 additions and 164 deletions.
  1. +1 −20 common/audio.cpp
  2. +1 −4 common/audio.h
  3. +0 −13 hu/hu_aap.cpp
  4. +16 −0 hu/hu_aap.h
  5. +134 −98 mazda/callbacks.cpp
  6. +16 −6 mazda/callbacks.h
  7. +1 −1 mazda/main.cpp
  8. +23 −22 mazda/outputs.cpp
View
@@ -1,7 +1,6 @@
#include "audio.h"
AudioOutput::AudioOutput(const char *outDev, bool halfVolume)
: halfVolume(halfVolume)
AudioOutput::AudioOutput(const char *outDev)
{
printf("snd_asoundlib_version: %s\n", snd_asoundlib_version());
logd("Device name %s\n", outDev);
@@ -54,24 +53,6 @@ void AudioOutput::MediaPacketAU1(uint64_t timestamp, const byte *buf, int len)
void AudioOutput::MediaPacket(snd_pcm_t *pcm, const byte *buf, int len)
{
//The output is super-loud on the car
if (halfVolume)
{
const int intCount = len / sizeof(int16_t);
if (audio_temp.size() < intCount)
audio_temp.resize(intCount);
int16_t* temp = audio_temp.data();
memcpy(temp, buf, intCount * sizeof(int16_t));
int16_t* tempEnd = temp + intCount;
while(temp < tempEnd)
{
//halve the volume
*temp >>= 1;
temp++;
}
buf = reinterpret_cast<byte*>(audio_temp.data());
}
snd_pcm_sframes_t framecount = snd_pcm_bytes_to_frames(pcm, len);
snd_pcm_sframes_t frames = snd_pcm_writei(pcm, buf, framecount);
if (frames < 0) {
View
@@ -14,11 +14,8 @@ class AudioOutput
snd_pcm_t* au1_handle = nullptr;
void MediaPacket(snd_pcm_t* pcm, const byte * buf, int len);
bool halfVolume = false;
std::vector<int16_t> audio_temp;
public:
AudioOutput(const char* outDev = "default", bool halfVolume = false);
AudioOutput(const char* outDev = "default");
~AudioOutput();
void MediaPacketAUD(uint64_t timestamp, const byte * buf, int len);
View
@@ -25,19 +25,6 @@
return ("hu_STATE Unknown error");
}
const char * chan_get (int chan) {
switch (chan) {
case AA_CH_CTR: return ("CTR");
case AA_CH_VID: return ("VID");
case AA_CH_TOU: return ("TOU");
case AA_CH_SEN: return ("SEN");
case AA_CH_MIC: return ("MIC");
case AA_CH_AUD: return ("AUD");
case AA_CH_AU1: return ("AU1");
case AA_CH_AU2: return ("AU2");
}
return ("UNK");
}
#include "hu_usb.h"
#include "hu_tcp.h"
View
@@ -27,6 +27,22 @@ enum HU_STATE
};
const char* state_get(int s);
const char* chan_get(int chan);
inline const char * chan_get (int chan) {
switch (chan) {
case AA_CH_CTR: return ("AA_CH_CTR");
case AA_CH_TOU: return ("AA_CH_TOU");
case AA_CH_SEN: return ("AA_CH_SEN");
case AA_CH_VID: return ("AA_CH_VID");
case AA_CH_AUD: return ("AA_CH_AUD");
case AA_CH_AU1: return ("AA_CH_AU1");
case AA_CH_AU2: return ("AA_CH_AU2");
case AA_CH_MIC: return ("AA_CH_MIC");
case AA_CH_BT: return ("AA_CH_BT");
}
return ("<Invalid>");
}
enum HU_FRAME_FLAGS
{
Oops, something went wrong.

0 comments on commit 77bac84

Please sign in to comment.