Switch to unified view

a/sc2src/sc2mpd.cpp b/sc2src/sc2mpd.cpp
...
...
303
    }
303
    }
304
}
304
}
305
305
306
void OhmReceiverDriver::Process(OhmMsgAudio& aMsg)
306
void OhmReceiverDriver::Process(OhmMsgAudio& aMsg)
307
{
307
{
308
    unsigned int bytes = 0;
309
    unsigned int allocbytes = 0;
310
    char *buf = NULL;
311
    bool needswap = false;
312
308
    if (aMsg.Audio().Bytes() == 0) {
313
    if (aMsg.Audio().Bytes() == 0) {
314
        if (aMsg.Halt()) {
315
            LOGDEB("OhmReceiverDriver::Process: empty message with halt flag "
316
                   "set\n");
317
            goto put_audio_message;
318
        } else {
309
        LOGDEB("OhmReceiverDriver::Process: empty message\n");
319
            LOGDEB("OhmReceiverDriver::Process: ignoring empty message\n");
310
        return;
320
            return;
321
        }
311
    }
322
    }
312
323
313
    m_obs.process(aMsg);
324
    m_obs.process(aMsg);
314
    if (aMsg.Halt()) {
325
    if (aMsg.Halt()) {
315
        LOGDEB("OhmReceiverDriver::Process: halt flag set in message\n");
326
        LOGDEB("OhmReceiverDriver::Process: halt flag set in message\n");
316
    }
327
    }
317
328
318
    unsigned int bytes = aMsg.Audio().Bytes();
329
    bytes = aMsg.Audio().Bytes();
319
    // We allocate a bit more space to avoir reallocations in the resampler
330
    // We allocate a bit more space to avoir reallocations in the resampler
320
    unsigned int allocbytes = bytes + 100; 
331
    allocbytes = bytes + 100;
321
    char *buf = (char *)malloc(allocbytes);
332
    buf = (char *)malloc(allocbytes);
322
    if (buf == 0) {
333
    if (buf == 0) {
323
        LOGERR("OhmReceiverDriver::Process: can't allocate " << 
334
        LOGERR("OhmReceiverDriver::Process: can't allocate " << 
324
               bytes << " bytes\n");
335
               bytes << " bytes\n");
325
        return;
336
        return;
326
    }
337
    }
327
338
328
    // Songcast data is always msb-first.  Convert to desired order:
339
    // Songcast data is always msb-first.  Convert to desired order:
329
    // depends on what downstream wants, and just as well we do it
340
    // depends on what downstream wants, and just as well we do it
330
    // here because we copy the buf anyway.
341
    // here because we copy the buf anyway.
331
    bool needswap = false;
332
    switch (m_eater->input_border) {
342
    switch (m_eater->input_border) {
333
    case AudioEater::BO_MSB: 
343
    case AudioEater::BO_MSB: 
334
        break;
344
        break;
335
    case AudioEater::BO_LSB: 
345
    case AudioEater::BO_LSB: 
336
        needswap = true; 
346
        needswap = true; 
...
...
348
        copyswap((unsigned char *)buf, aMsg.Audio().Ptr(), bytes, aMsg.BitDepth());
358
        copyswap((unsigned char *)buf, aMsg.Audio().Ptr(), bytes, aMsg.BitDepth());
349
    } else {
359
    } else {
350
        memcpy(buf, aMsg.Audio().Ptr(), bytes);
360
        memcpy(buf, aMsg.Audio().Ptr(), bytes);
351
    }
361
    }
352
362
363
put_audio_message:
353
    AudioMessage *ap = new 
364
    AudioMessage *ap = new 
354
        AudioMessage(aMsg.BitDepth(), aMsg.Channels(), aMsg.Samples(),
365
        AudioMessage(aMsg.BitDepth(), aMsg.Channels(), aMsg.Samples(),
355
                     aMsg.SampleRate(), aMsg.Halt(), buf, allocbytes);
366
                     aMsg.SampleRate(), aMsg.Halt(), buf, allocbytes);
356
367
357
    // There is nothing special we can do if put fails: no way to
368
    // There is nothing special we can do if put fails: no way to